package com.akina.akiOJ.controller;

import com.akina.akiOJ.annotation.AuthCheck;
import com.akina.akiOJ.common.BaseResponse;
import com.akina.akiOJ.common.ErrorCode;
import com.akina.akiOJ.common.ResultUtils;
import com.akina.akiOJ.constant.UserConstant;
import com.akina.akiOJ.exception.BusinessException;
import com.akina.akiOJ.model.dto.question.QuestionQueryRequest;
import com.akina.akiOJ.model.dto.questionsubmit.QuestionSubmitAddRequest;
import com.akina.akiOJ.model.dto.questionsubmit.QuestionSubmitQueryRequest;
import com.akina.akiOJ.model.entity.Question;
import com.akina.akiOJ.model.entity.QuestionSubmit;
import com.akina.akiOJ.model.entity.User;
import com.akina.akiOJ.model.vo.QuestionSubmitVO;
import com.akina.akiOJ.service.QuestionService;
import com.akina.akiOJ.service.QuestionSubmitService;
import com.akina.akiOJ.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 题目提交接口
 *
 * @author <a href="https://github.com/liakina">Aki</a>
 * @from <a href="https://akina.icu">在线判题</a>
 */
@RestController
@RequestMapping("/question_submit")
@Slf4j
@Deprecated
public class QuestionSubmitController {

    @Resource
    private QuestionSubmitService questionSubmitService;

    @Resource
    private UserService userService;
   /* @Resource
    private QuestionService questionService;

    *//**
     * 提交 / 取消提交
     *
     * @param questionSubmitAddRequest
     * @param request
     * @return resultNum 本次提交变化数
     *//*
    @PostMapping("/")
    public BaseResponse<Long> doQuestionSubmit(@RequestBody QuestionSubmitAddRequest questionSubmitAddRequest,
                                         HttpServletRequest request) {
        if (questionSubmitAddRequest == null || questionSubmitAddRequest.getQuestionId() <= 0) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        // 登录才能提交
        final User loginUser = userService.getLoginUser(request);
        //long questionId = questionSubmitAddRequest.getQuestionId();
        long result = questionSubmitService.doQuestionSubmit(questionSubmitAddRequest, loginUser);
        return ResultUtils.success(result);
    }

    *//**
     * 分页获取题目列表（仅管理员）
     *
     * @param questionSubmitQueryRequest
     * @param request
     * @return
     *//*
    @PostMapping("/list/page")
    public BaseResponse<Page<QuestionSubmitVO>> listQuestionSubmitByPage(@RequestBody QuestionSubmitQueryRequest questionSubmitQueryRequest,
                                                                         HttpServletRequest request) {
        long current = questionSubmitQueryRequest.getCurrent();
        long size = questionSubmitQueryRequest.getPageSize();
        //从数据库查询到原始的分页信息。
        Page<QuestionSubmit> questionSubmitPage = questionSubmitService.page(new Page<>(current, size),
                questionSubmitService.getQueryWrapper(questionSubmitQueryRequest));
        //返回脱敏信息。
        User loginUser = userService.getLoginUser(request);
        //Request用来获取当前用户的
        return ResultUtils.success(questionSubmitService.getQuestionSubmitVOPage(questionSubmitPage, loginUser));
    }

    //@PostMapping("/")
*/
}
